 <template>
  <div class="selects">
    <div class="selectTables">
      <el-popover placement="bottom-end" width="500px" trigger="focus">
        <el-input
          placeholder="选择药品"
          slot="reference"
          v-model="selectParams.keyword"
          @input="getDrugItem()"
        >
          <i slot="suffix" class="el-input__icon el-icon-search"></i>
        </el-input>

        <el-table
          v-loading="selectParams.chufangLogding"
          height="300"
          @current-change="xuanzeData"
          highlight-current-row
          :data="selectParams.cfList"
          style="width: 100%"
        >
          <el-table-column type="index" label="序号" width="50">
          </el-table-column>
          <el-table-column label="名称" prop="name" width="150">
          </el-table-column>
          <el-table-column label="价格" prop="price" width="50">
          </el-table-column>
        </el-table>
        <el-pagination
          :current-page="selectParams.page"
          :page-size="selectParams.limit"
          @current-change="handlePagination"
          :total="selectParams.pageCount"
          layout="prev, pager, next"
        >
        </el-pagination>
      </el-popover>
    </div>
  </div>
</template>
<script>
export default {
  props: ["thatF"],
  data() {
    return {
      selectParams: {
        keyword: "",
        page: 1,
        limit: 15,
        pageCount: 0,
        chufangLogding:false,
        cfList:[],
      },
     
    };
  },
  mounted() {
    this.getDrugItem();
  },
  methods: {
      handlePagination(e) {
      this.selectParams.chufangLogding = true;
      this.selectParams.page = e;

     this.getDrugItem();
     
    },
      xuanzeData(item) {
        
        //  if(item.usage){
        //    this.thatF.thatF.geiyao.forEach(gy1=>{
        //         if(gy1.name==item.usage){
        //           item.usage=gy1.id;
        //         }
        //       })
        //  }
      if( this.thatF.cfListSub.findIndex(res=>res.id==item.id)===-1){
        this.thatF.cfListSub = this.thatF.cfListSub.concat(item);
      }
      // if(item.usage){
      //      this.thatF.geiyao.forEach(gy1=>{
      //           if(gy1.name==item.usage){
      //             item.usage=gy1.id;
      //           }
      //         })
      //    }

    console.log(" this.thatF.cfListSub", this.thatF.cfListSub)
     
    },
    //处方列表
    getDrugItem() {
      let d = {
        keyword: this.selectParams.keyword,
        page: this.selectParams.page,
        limit: this.selectParams.limit,
      };
       this.selectParams.chufangLogding = true;
      this["_API"].getClinic_doctorgetDrugItem(d).then((res) => {
        this.selectParams.cfList = res.data.list;

        this.selectParams.cfList.forEach((res) => {
          res.used_frqu=res.used_frqu?res.used_frqu:'';
          res.is_skin_test = res.is_skin_test === 1 ? true : false;
        });
        this.selectParams.pageCount = res.data.count;
        this.selectParams.chufangLogding = false;
      });
    },
  },
};
</script>